﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;

namespace SemestralniPraceY35VAN
{
    class BeenHere
    {
        /// <summary>
        /// Properties of the BeenHere.
        /// </summary>
        private Hashtable properties;

        /// <summary>
        /// 
        /// </summary>
        public bool Me { get { if (properties.ContainsKey("id")) return bool.Parse((string)properties["me"]); else return false; } }

        /// <summary>
        /// 
        /// </summary>
        public bool Friends { get { if (properties.ContainsKey("type")) return bool.Parse((string)properties["friends"]); else return false; } }

        /// <summary>
        /// Constructs an object representing a special.
        /// </summary>
        /// <param name="beenhere">XML node with information about the beenhere</param>
        public BeenHere(XmlNode beenhere)
        {
            properties = new Hashtable();

            if (beenhere.Name == "beenhere")
            {
                for (int i = 0; i < beenhere.ChildNodes.Count; i++)
                {
                    switch (beenhere.ChildNodes[i].Name)
                    {
                        default:
                            properties.Add(beenhere.ChildNodes[i].Name, beenhere.ChildNodes[i].InnerText);
                            break;
                    }
                }
            }
            else
            {
                throw new IOException("Not BeenHere!");
            }
        }
    }
}
